


%macro preg(group1,group2,group3);
CA_&group1. = CA_&group2. - CA_&group3.;
CA_medi_&group1.  = (CA_&group2./CA_&group1.)*CA_medi_&group2.  - (CA_&group3./CA_&group1.)*CA_medi_&group3.;
CA_priv_&group1.  = (CA_&group2./CA_&group1.)*CA_priv_&group2.  - (CA_&group3./CA_&group1.)*CA_priv_&group3.;
CA_self_&group1.  = (CA_&group2./CA_&group1.)*CA_self_&group2.  - (CA_&group3./CA_&group1.)*CA_self_&group3.;
CA_o_ins_&group1. = (CA_&group2./CA_&group1.)*CA_o_ins_&group2. - (CA_&group3./CA_&group1.)*CA_o_ins_&group3.;

CA_&group1._NED = CA_&group2._NED - CA_&group3._NED;
CA_medi_&group1._NED  = (CA_&group2._NED/CA_&group1._NED)*CA_medi_&group2._NED   - (CA_&group3._NED/CA_&group1._NED)*CA_medi_&group3._NED;
CA_priv_&group1._NED  = (CA_&group2._NED/CA_&group1._NED)*CA_priv_&group2._NED   - (CA_&group3._NED/CA_&group1._NED)*CA_priv_&group3._NED; 
CA_self_&group1._NED  = (CA_&group2._NED/CA_&group1._NED)*CA_self_&group2._NED   - (CA_&group3._NED/CA_&group1._NED)*CA_self_&group3._NED;
CA_o_ins_&group1._NED = (CA_&group2._NED/CA_&group1._NED)*CA_o_ins_&group2._NED  - (CA_&group3._NED/CA_&group1._NED)*CA_o_ins_&group3._NED;

CA_&group1._ED = CA_&group2._ED - CA_&group3._ED;
CA_medi_&group1._ED  = (CA_&group2._ED/CA_&group1._ED)*CA_medi_&group2._ED   - (CA_&group3._ED/CA_&group1._ED)*CA_medi_&group3._ED; 
CA_priv_&group1._ED  = (CA_&group2._ED/CA_&group1._ED)*CA_priv_&group2._ED   - (CA_&group3._ED/CA_&group1._ED)*CA_priv_&group3._ED; 
CA_self_&group1._ED  = (CA_&group2._ED/CA_&group1._ED)*CA_self_&group2._ED   - (CA_&group3._ED/CA_&group1._ED)*CA_self_&group3._ED;
CA_o_ins_&group1._ED = (CA_&group2._ED/CA_&group1._ED)*CA_o_ins_&group2._ED  - (CA_&group3._ED/CA_&group1._ED)*CA_o_ins_&group3._ED; 

%mend;

%macro pull(ed);
data inter.ins_23_reprod_ca_preg;
   set inter.ins_23_reprod_ca;
   %preg(female_p,female,female_np);
   %preg(female_p_pub,female_pub,female_np_pub);
   %preg(female_p_non_prof,female_non_prof,female_np_non_prof);
   %preg(female_p_for_prof,female_for_prof,female_np_for_prof);
   %preg(female_p_other,female_other,female_np_other);
run;
%mend;
%pull(ed);

proc means data = test;
   var CA_female CA_female_p CA_female_np CA_medi_female CA_medi_female_p CA_medi_female_np;
run;
